package com.timerecording.controller;


import java.util.HashMap;

/**
 * @author smz41
 */
public class BaseController {


    /** 提供请求成功的情况下
     * @description: TODO
     * @author smz
     * @version 1.0
     */
    public HashMap<String, Object> setResultOk(Object data) {
        return setResult(200,"ok",data);
    }

    public HashMap<String, Object>setResultSuccess(String msg){
        return setResult(200,msg,null);
    }


    public HashMap<String, Object>setResultError(String msg){
        return setResult(500,msg,null);
    }

    /**
     * @param code code 200 处理成功 500 处理失败
     * @param msg  响应错误内容
     * @param data 响应的数据
     * @return
     */
    public HashMap<String, Object> setResult(Integer code, String msg, Object data) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("code", code);
        result.put("msg", msg);
        result.put("data", data);
        return result;
    }
}
